#include <iostream>
#include <string>

using namespace std;

int main(){
    string s;
    cin>>s;
    long n1=0,n2=0,n3=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='C')
            n1++;
        else if(s[i]=='H')
            n2+=n1;
        else if(s[i]=='N')
            n3+=n2;
    }
    cout<<n3<<endl;

    return 0;
}
